package com.chen.subject.domain.Scheduled;

import com.chen.subject.domain.service.SubjectLikedDomainService;
import com.xxl.job.core.context.XxlJobHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Slf4j
public class ScheduledSyncLikedJob {
    @Resource
    private SubjectLikedDomainService subjectLikedDomainService;

    // 添加定时任务
    @Scheduled(cron = "0 0/2 * * * ?") // cron表达式：每2秒执行一次行
    public void syncLikedJobHandler() throws Exception {
        log.info("syncLikedJobHandler.start");
        try {
            subjectLikedDomainService.syncLiked();
        } catch (Exception e) {
            log.info("syncLikedJobHandler.error:{}" ,e.getMessage());
        }
    }
}
